<template>
  	<a-row>
			<!-- v-userAuth="'D11'" -->
			<NoAuthPage v-showNoAuth="['D12-1','D13-1']" :imgBoxStyle="{height:'40vh',margin:'0 10px 10px'}"/>
			
			<div v-userAuth="'D12-1'">
  	 	<p style="color:var(--themeColor);margin-top:0 ;" class="tabs-top">{{$t('Directory')}}</p>
  	 	<div style="margin:0 0 1em 0 ">
			<a-tooltip placement='bottom' v-userAuth="'D12-2'">
        <template slot='title'>
          <span>{{$t('Create')}}</span>
        </template>
        <a-button type="primary" style="margin-right:1em" @click="createfile = true">
					<!-- <a-icon :component="add"/> -->
					<!-- <i class="icon icon-new16f"></i> -->
					
					<Iconfont class="icon" type="icon-new16f"></Iconfont>
				</a-button>
      </a-tooltip>
      <a-tooltip placement='bottom' v-userAuth="'D12-3'">
				<template slot='title'>
					<span>{{$t('Quota')}}</span>
				</template>
				<a-button :disabled="selectedRowKeys.length==0" type='primary' style="margin-right:1em" @click="openmodal('aquota')">
					<!-- <a-icon :component="quota"/> -->
					<!-- <i class="icon icon-quota16f"></i> -->
						<Iconfont class="icon" type="icon-quota16f"></Iconfont>
				</a-button>
			</a-tooltip>
            <!-- <a-tooltip placement='bottom'>
				<template slot='title'>
					<span>{{$t('Join-to-File-sharing')}}</span>
				</template>
				<a-button type="primary" @click="openmodal('addto')">
					<a-icon :component="add"/>
				</a-button>
			</a-tooltip> -->
			<a-tooltip placement='bottom' v-userAuth="'D12-4'">
				<template slot='title'>
					<span>{{$t('Set-pool')}}</span>
				</template>
				<a-button :disabled="selectedRowKeys.length==0" type='primary' @click="openmodal('setpool')" style="margin-right:1em;">
					<!-- background: #06bcad;border-color: #06bcad; -->
	        <!-- <a-icon :component="sure"/> -->
					<!-- <i class="icon icon-storage16f"></i> -->
						<Iconfont class="icon" type="icon-storage16f"></Iconfont>
	       </a-button>
			</a-tooltip>
			<a-tooltip placement='bottom' v-userAuth="'D12-5'">
        <template slot='title'>
          <span>{{$t('Delete')}}</span>
        </template>
        <a-button :disabled="selectedRowKeys.length==0" type='danger' style="margin-right:1em"  @click="openmodal('delfile')">
					<!-- <a-icon :component="del"/> -->
					<!-- <i class="icon icon-error16f"></i> -->
						<Iconfont class="icon" type="icon-error16f"></Iconfont>
				</a-button>
      </a-tooltip>
      </div>
  	 	<a-table
				:columns="columns"
				:dataSource="fliedata"
				:loading="loading"
				size="small" 
		   	:rowSelection='{type:"radio",onSelect:onSelectone, onChange:onSelectChange, selectedRowKeys:selectedRowKeys,}'
				bordered :pagination='pagination' 
				rowKey="name" :locale="defaultSetting"
				
			>
			<template slot="max_files" slot-scope="text, record">
				<span v-if="text && text!=''">{{text}}</span>
				<span v-else>-</span>
			</template>
			<template slot="max_bytes" slot-scope="text, record">
				<span v-if="text && text!=''">{{text}}</span>
				<span v-else>-</span>
			</template>
			<template slot="data_pool" slot-scope="text, record">
				<span v-if="text && text!=''">{{text}}</span>
				<span v-else>-</span>
			</template>
  	 		<span slot="status" slot-scope='status'>
				<span v-if="status == 'normal'" >
					<a-tag color="green">{{$t('Actionable')}}</a-tag><!--可操作-->
				</span>
				<span v-if="status == 'link'" >
					<a-tag color="orange">{{$t('Connecting')}}</a-tag><!--连接中-->
				</span>
				<span v-if="status == 'copy'" >
					<a-tag color="orange">{{$t('Copying')}}</a-tag><!--复制中-->
				</span>
				<span v-if="status == 'rollback'" >
					<a-tag color="orange">{{$t('Rolling-back')}}</a-tag><!--回滚中-->
				</span>
				<span v-if="status == 'lun'" >
					<a-tag color="orange" style="padding:0 1.3em">lun</a-tag>
				</span>
				<span v-if="status == 'clone'" >
					<a-tag color="orange">{{$t('Cloning')}}</a-tag><!--克隆中-->
				</span>
				<span v-if="status == 'flatten'" >
					<a-tag color="orange">{{$t('Separating')}}</a-tag><!--分离中-->
				</span>
				<!-- <span v-else >{{status}} 
					<a-spin>
					<a-icon slot="indicator" type="loading" style="font-size: 24px" spin />
					</a-spin>
              </span> -->
			</span>
			   <!-- <a slot="data_pool" slot-scope="text" href="javascript:;">
		        <a-select defaultValue="data" style="width: 120px" @change="handleChange">
			      <a-select-option v-for="item in $store.state.baseblock.rbd_pool" :value='item'>{{item}}</a-select-option>
			    </a-select>
			    <a-button type='primary' @click="openmodal('setpool')" class="quato" style="margin-left:1em;background: #06bcad;border-color: #06bcad;">
	            	<a-icon :component="sure"/>
	            </a-button>
		    </a> -->
		    
		    <!-- <a slot="operation" slot-scope="text" href="javascript:;">
			    <a-tooltip placement='bottom'>
		            <template slot='title'>
		                <span>配额</span>
		            </template>
		            <a-button type='primary' class="quato" style="margin-left:1em" @click="openmodal('aquota')">
		            	<a-icon :component="quota"/>
		            </a-button>
		        </a-tooltip>
	            <a-tooltip placement='bottom'>
		            <template slot='title'>
		                <span>加入到文件共享</span>
		            </template>
		            <a-button type="primary" style="margin-left:1em" @click="openmodal('addto')">
		            	<a-icon :component="add"/>
		            </a-button>
		        </a-tooltip>
		    </a> -->

  	 	</a-table>
			</div>
  	 	<!--配额-->
  	 	<a-modal 
				:title="$t('Quota')" v-model='aquota' 
				@cancel='cancelhandle' width='30%' 
				@ok='toquota' 
		   	:cancelText="$t('Cancel')" 
				:okText="$t('Sure')" 
				:maskClosable='false' v-dragModal>
        <a-spin size="large" style="position:absolute;left:50%; top:50%; transform: translate(-50%, -50%);z-index:1;background:rgba(255,255,255,.6);padding:10%" tip="Submit successfully Loading..." v-if="spinning == true"></a-spin>
		    <a-form :form='form'>
		      <a-form-item :label="$t('File-quota')" v-bind='lang=="zh"?formlayout:formlayout4'>
	                <!-- <a-input-number v-decorator="['files',{
	                    rules:[{required:true,message: $t('Enter') + $t('File-quota')},{pattern:/^\d{1,18}$/,message: $t('Quota_rule_prompt')}],
						initialValue:max_files
	                }]" :min="1" :placeholder="$t('E-g')+'100'"  style="width:100%">
	                </a-input-number> -->
						<a-input v-decorator="['files',{
	                rules:[{pattern:/^([1-9]|[1-9]\d{1,9})$/,message: $t('Quota_rule_prompt')}],
									initialValue:max_files==0?'':max_files
	                }]" :placeholder="$t('E-g')+'100'"  style="width:100%">
									<!-- {required:true,message: $t('Enter') + $t('File-quota')}, -->
	          </a-input>
	        </a-form-item>
					<a-row>
					<a-col :span='18'>
						<a-form-item :label="$t('Capacity-quota')" v-bind='lang=="zh"?formlayout3:formlayout2'
							:validate-status="sizeValidateStatus"
							:help="sizeValidateHelp">
							<!-- <a-input-number v-decorator="['size',{
										rules:[{required:true,message:$t('Enter') + $t('Capacity-quota')},
											   {pattern:/^\d{1,18}$/,message: $t('Quota_rule_prompt')}],
											   initialValue:Number(oldsize)}]" 
											   :min="1" :placeholder="$t('E-g')+'100'" style="width:100%">
									注释{pattern:/^[0-9a-zA-Z_.-]+$/,message: $t('Not_enter_special_characters')}
							</a-input-number> -->
							<a-input v-decorator="['size',{
											rules:[{pattern:/^[1-9]\d{0,9}$/,message: $t('Quota_rule_prompt'),validator:quotaValueValidator}],
											initialValue:Number(oldsize)==0?'':Number(oldsize)}]" 
											:placeholder="$t('E-g')+'100'" style="width:100%"
											@change="quotaSizeChange">
												 <!-- {required:true,message:$t('Enter') + $t('Capacity-quota')}, -->
							</a-input>  
						</a-form-item>
					</a-col>
					<a-col :span='6'>
						<a-form-item label="" :validate-status="unitValidateStatus" :help="unitValidateHelp">
							<a-select v-decorator="['unit',{
									rules:[{validator:quotaUnitValidator}],
									initialValue:oldunit==''?undefined:oldunit}]"
									:placeholder="$t('Choose')+$t('Unit')" style="width:100%"
									@change="quotaUnitChange" allowClear>
									<!-- {required:true,message:$t('Choose') + $t('Unit')}, -->
									<!-- {pattern:/^[0-9a-zA-Z_]+$/,message:$t('Not_enter_special_characters')} -->
								<a-select-option v-for='u in uint' :key='u.val'>{{u.label}}</a-select-option>
							</a-select>
						</a-form-item>
					</a-col>
				</a-row>
		    </a-form>
		</a-modal>
		<!--设置存储池-->
		<a-modal :title="$t('Set-pool')" v-model='setpool' @cancel='cancelhandle' width='35%' @ok='tosetpool' 
				 :cancelText="$t('Cancel')" :okText="$t('Sure')" :maskClosable='false' v-dragModal>
        	<a-spin size="large" style="position:absolute;left:50%; top:50%; transform: translate(-50%, -50%);z-index:1;background:rgba(255,255,255,.6);padding:10%" tip="Submit successfully Loading..." v-if="spinning == true"></a-spin>
		    <a-form :form='form2'>
		      <a-form-item :label="$t('Pool')+$t('Name')" v-bind='formlayout' has-feedback>
						<a-select v-decorator="['data_pool',{
							rules:[{required:true,message:$t('Choose')+$t('Pool')+$t('Name')}]
						}]" :placeholder="$t('Choose')+$t('Pool')+$t('Name')"
							@change="changePool">
							<!-- <a-select-option v-for="(item,index) in poollist" :value='item' :key="index"> -->
							<a-select-option v-for="(item,index) in poollist" :value='item.poolnum' :key="index">
								{{item.poolname}}
							</a-select-option>
						</a-select>
	        </a-form-item>
		    </a-form>
			<!-- <p style="color:#fd3371; text-align:center">{{$t('Set-pool-tip')}}</p> -->
		</a-modal>
		<!--创建文件夹-->
		<a-modal :title="$t('Create')+$t('Folder')" v-model='createfile' @cancel='cancelhandle' 
				 width='35%' @ok='tocreatefile' :cancelText="$t('Cancel')" 
				 :okText="$t('Sure')" :maskClosable='false' v-dragModal>
        	<a-spin size="large" style="position:absolute;left:50%; top:50%; transform: translate(-50%, -50%);z-index:1;background:rgba(255,255,255,.6);padding:10%" tip="Submit successfully Loading..." v-if="spinning == true"></a-spin>
		    <a-form :form='form3'>
		      	<a-form-item :label="$t('File-system')+$t('Name')" v-bind='formlayout' has-feedback>
					<a-select v-decorator="['fs_name',{
						rules:[{required:true,message:$t('Choose')+$t('File-system')+$t('Name')}]
					}]" :placeholder="$t('Choose')+$t('File-system')+$t('Name')">
						<a-select-option v-for="(item,index) in fsnamedata" :value='item' :key="index">
							{{item}}
						</a-select-option>
					</a-select>
	            </a-form-item>
				<a-form-item  :label="$t('Folder')+$t('Name')" v-bind='formlayout' has-feedback>
					<a-input v-decorator="['dir_name',{
						rules:[{required:true,message:$t('Enter')+$t('Folder')+$t('Name')},
						{pattern:namePattern,message:$t('Not_enter_special_characters')}]
					}]" :placeholder="$t('Enter')+$t('Folder')+$t('Name')"></a-input>
	            </a-form-item>
		    </a-form>
		</a-modal>
    <Snap @omodal='updflag' :fileSystemNames="fsnamedata" v-userAuth="'D13-1'"></Snap>

  </a-row>
</template>
<script>
	import Snap from './snap'
	// import quota from '../../../../../static/images/svg/ic_quota_normal.svg'
	// import add from '../../../../../static/images/svg/ic_newly_normal.svg'
	// import del from '../../../../../static/images/svg/ic_delete_normal.svg'
	// import sure from '../../../../../static/images/svg/ic_storage_white.svg'
	import EmptyData from '@/components/common/EmptyData'
	import NoAuthPage from '@/components/common/NoAuthPage'

	import request from '@/request/request'

	export default {
		// template: '<a-icon :component="quota,sure,add,del" />',
    	components:{ Snap, EmptyData, NoAuthPage },
		data() {
		  return {
        form:this.$form.createForm(this),
        form2:this.$form.createForm(this),
        form3:this.$form.createForm(this),
		    	// data,
		    columns :[
					// { title: this.$t('File')+this.$t('Name'), dataIndex: 'name', key: 'name' },
					{ title: this.$t('Directory_Index'), dataIndex: 'name', key: 'name',ellipsis: true, },
					{ title: this.$t('Edit')+this.$t('Time'), dataIndex: 'last_change', key: 'last_change',ellipsis: true, },
					{ title: this.$t('Size'), dataIndex: 'used', key: 'used',ellipsis: true, },
					{ title: this.$t('File-quota'), dataIndex: 'max_files', key: 'max_files',scopedSlots:{customRender:'max_files'},ellipsis: true, },
					{ title: this.$t('Capacity-quota'), dataIndex: 'max_bytes', key: 'max_bytes',scopedSlots:{customRender:'max_bytes'},ellipsis: true, },
					{ title: this.$t('Pool')+this.$t('Name'), dataIndex: 'data_pool',key: 'data_pool',scopedSlots:{customRender:'data_pool'},ellipsis: true,},
					// { title: this.$t('Status'), dataIndex: 'status',key: 'status',scopedSlots:{customRender:'status'}},
				],
		    // quota,
		    // sure,
		    // add,
				// del,
		    pagination:{
	        defaultPageSize:5,
	        showTotal: total => `${this.$t('A-total-of')} ${total} ${this.$t('Data')}`,
	        showSizeChanger:true,
	        pageSizeOptions: ['5', '10', '15', '20'],
	        onShowSizeChange:(current, pageSize)=>this.pageSize = pageSize,
					buildOptionText: (props) => `${props.value} / ${this.$t('page')}`
        },
        formlayout:{
	        labelCol:{span:6},
	        wrapperCol:{span:18}
	      },
				formlayout2:{
	        labelCol:{span:10},
	        wrapperCol:{span:14}
	      },
				formlayout3:{
	        labelCol:{span:8},
	        wrapperCol:{span:16}
	      },
				formlayout4:{
	        labelCol:{span:7},
	        wrapperCol:{span:17}
	    	},
        uint:[{val:'KiB',label:'KiB'},{val:'MiB',label:'MiB'},{val:'GiB',label:'GiB'},{val:'TiB',label:'TiB'}],
				aquota:false,
				setpool:false,
				createfile:false,
				poollist:[],
				fliedata :[],
				chosedata:'',
				chose:'',
				records:'',
				loading:true,
				spinning:false,	   
				oldsize:'',
				oldunit:'',
				fsnamedata:'',
				max_files: '',
				selectedRowKeys: [],
				lang: this.$store.state.language,
				defaultSetting: {emptyText:<EmptyData />},
				quotaInputValue: '',
				quotaUnitValue: '',
				sizeValidateStatus: '',
				unitValidateStatus: '',
				sizeValidateHelp: '',
				unitValidateHelp: '',
				targetPoolName: ''
			}
		},
		computed:{
			getchosefile() {
				return this.$store.state.chosefile
			},
			getlanguage(){
				return this.$store.state.language
			}
		},
		watch:{
			getlanguage(val){
				this.lang = val;
				this.columns=[
					// { title: this.$t('File')+this.$t('Name'), dataIndex: 'name', key: 'name' },
					{ title: this.$t('Directory_Index'), dataIndex: 'name', key: 'name' },
					{ title: this.$t('Edit')+this.$t('Time'), dataIndex: 'last_change', key: 'last_change' },
					{ title: this.$t('Size'), dataIndex: 'used', key: 'used' },
					{ title: this.$t('File-quota'), dataIndex: 'max_files', key: 'max_files' },
					{ title: this.$t('Capacity-quota'), dataIndex: 'max_bytes', key: 'max_bytes' },
					{ title: this.$t('Pool')+this.$t('Name'), dataIndex: 'data_pool',key: 'data_pool'},
					// { title: this.$t('Status'), dataIndex: 'status',key: 'status',scopedSlots:{customRender:'status'}},
				]
			}
		},
		created(){
			this.addListenerfun('fsview',this.getdata) //通知交互：监听变化 刷新
		},
		mounted(){
			this.getdata()
			this.$store.commit('getchosefile', {
				chosefile: '',
			})
			this.getbasedata();
			this.getpool();
		},
		methods: {
			getdata(){
				this.loading = true
				// this.$axios.get(this.allurl+'cephfs/struct').then(res=>{
				request('get', 'cephfs/operation/').then(res=>{
					// console.log('获取目录结构',res)
					// for(var i=0;i<res.data.length;i++){  //数据单位处理
					// 	if(res.data[i].max_bytes == -1){
					// 		res.data[i].max_bytes = -1
					// 	}else{
					// 		res.data[i].max_bytes = this.bytesToSize(res.data[i].max_bytes)
					// 	}
					// 	res.data[i].used = this.bytesToSize(res.data[i].used)
					// 	for(var j=0;j<res.data[i].children.length;j++){
					// 		if(res.data[i].children[j].max_bytes == -1){
					// 			res.data[i].children[j].max_bytes = -1
					// 		}else{
					// 			res.data[i].children[j].max_bytes = this.bytesToSize(res.data[i].children[j].max_bytes)
					// 		}
					// 		res.data[i].children[j].used = this.bytesToSize(res.data[i].children[j].used)
					// 	}
					// }
					if(res.data.flag == 1) {
						this.model(res.data.id) //返回模板
						this.notice(res.data.id,res.data.params,res.data.flag) //通知列表显示
					}else {
						// this.fliedata = res.data
						this.fliedata = res.data
						// console.log('data', this.fliedata)
						if(this.records !== ''){  //再次编辑获取最新数据
							for (const item of this.fliedata) {
								for (const subItem of item.children) {
									if(this.records.name == subItem.name){
										this.records = subItem;
									}
								}
							}
							try{
								this.oldsize = this.records.max_bytes.split(' ')[0]
								this.oldunit = this.records.max_bytes.split(' ')[1]
							}catch{
								this.oldsize = ''
								this.oldunit = ''
							}
						}
						// this.loading = false
					}
				}).catch(err => {
					this.loading = false;
				}).finally(() => {
					this.loading = false;
				})
			},
			updflag(val){
				this.getdata()
			},
			getbasedata(){
				// this.$axios.get(this.allurl+'cephfs/struct/_info').then(res=>{cephfs/operation/getFileSystemNameAll
				request('post', 'cephfs/operation/getFSAndOneDepthName').then(res=>{
					// console.log('获取文件系统名称', res)
					if(res.data.flag != 1) {
						this.fsnamedata = [];
						for(let key in res.data) {
							this.fsnamedata.push(key);
						}
					}
				})
			},
			getpool(){
				// this.$axios.get(this.allurl+'cephfs/layout/_info').then(res=>{
				request('post', 'pool/getRbdInfoAll',{
					applications:['cephfs']
				}).then(res=>{
					this.poollist = res.data
				})
			},
			onSelectChange(selectedRowKeys,selectedRow) {
      	this.selectedRowKeys = selectedRowKeys;
				// console.log(selectedRow)
				if(selectedRow[0].max_bytes) {
					this.quotaInputValue = selectedRow[0].max_bytes.substring(0,selectedRow[0].max_bytes.indexOf(' '));
					this.quotaInputValue = Number(this.quotaInputValue);
					this.quotaUnitValue = selectedRow[0].max_bytes.substring(selectedRow[0].max_bytes.indexOf(' ')+1);
				}else {
					this.quotaInputValue = '';
					this.quotaUnitValue = '';
				}
			},
			onSelectone(record, selected, selectedRows){
				this.records = {...record}  //选中的一条信息
				if(this.records.max_files) {
					if(this.records.max_files.indexOf('.') != -1) {
						let max_files = this.records.max_files.substring(0, this.records.max_files.indexOf(' '));
						if(this.records.max_files.indexOf('K') != -1) {
							this.records.max_files = max_files * (10**3);
						}else if(this.records.max_files.indexOf('M') != -1) {
							this.records.max_files = max_files * (10**6);
						}else if(this.records.max_files.indexOf('G') != -1) {
							this.records.max_files = max_files * (10**9)
						}else if(this.records.max_files.indexOf('T') != -1) {
							this.records.max_files = max_files * (10**12)
						}else if(this.records.max_files.indexOf('P') != -1) {
							this.records.max_files = max_files * (10**15)
						}
					}
					this.max_files = this.records.max_files;
				}else {
					this.max_files = '';
				}
				this.$store.commit('getchosefile', {
					chosefile: this.records,
				})
				try{
					this.oldsize = this.records.max_bytes.split(' ')[0]
					this.oldunit = this.records.max_bytes.split(' ')[1]
				}catch{
					this.oldsize = ''
					this.oldunit = ''
				}
			},
		    openmodal(name){
				if(this.records !== ''){
					// this.changeFileQuotaValue(this.records.max_files);
					if(this.records.children){
						this.$notification['error']({
							message: this.$t('Not-allow-to-do')
						})
					}
					else{
						for (const item of this.fliedata) {
							for (const subItem of item.children) {
								if(this.records.name == subItem.name){
									this.records = subItem
								}
							}
						}
						if(this.records.status !== 'normal' ){
							this.$notification['error']({
								message: this.$t('Try-later')
							})
						}
						else{
							if(name=='aquota'){
								this.aquota = true
							}else if(name == 'addto'){
								this.addto()
							}else if(name == 'setpool'){
								this.setpool = true
							}else if(name == 'delfile'){
								this.delfile()
							}
						}
					}
				}else{
		          this.$notification['error']({
		            message:this.$t('Choose')+this.$t('Operating-object')
		          })
		        }
			},
			//创建文件
			tocreatefile(e){
				e.preventDefault();
				this.form3.validateFields((err,value)=>{
					if(!err){
						this.spinning = true
						// this.$axios.post(this.allurl+'cephfs/struct',value).then(res=>{
						request('put', 'cephfs/operation/',{
							dir_name: value.dir_name,
							fs_name: value.fs_name
						}).then(res=>{
							this.model(res.data.id) //返回模板
              this.notice(res.data.id, res.data.params, res.data.flag) //通知列表显示
							// this.gettask()  //任务栏信息
							this.spinning = false
							this.createfile=false
							this.selectedRowKeys = [];
							this.form3.resetFields();
							this.getdata()
							this.$store.commit('toUpdateSnapPath' ,true);
						}).catch(err => {
							this.spinning = false;
							this.createfile = false;
							this.form3.resetFields();
						})
					}
				})	
			},
			//设置存储池
			tosetpool(e){
				e.preventDefault();
				this.form2.validateFields((err,value)=>{
					if(!err){
						this.spinning = true
						// this.$axios.post(this.allurl+'cephfs/layout',{
						request('post', 'cephfs/operation/setDataPool',{	
							fs_name: this.records.fs_name, //文件系统名称						
							dir_name: this.records.name, //路径
							data_pool: value.data_pool, //数据存储池名称
							pool_name: this.targetPoolName
							// fs_name:this.records.fs_name,
							// path:this.records.path,
							// data_pool:value.data_pool
						}).then(res=>{
							this.model(res.data.id) //返回模板
              this.notice(res.data.id, res.data.params, res.data.flag) //通知列表显示
							// this.gettask()  //任务栏信息
							this.spinning = false
							this.setpool=false
							this.form2.resetFields();
							this.getdata()
							this.targetPoolName = ''
						})
					}
				})				
			},

		    // addto(){
	        //     this.$confirm({
	        //         title: this.$t('Join-to-File-sharing'),
	        //         content:'你确定要将 '+this.data+' 加入到文件共享吗？',
	        //         okText:'确定',
	        //         okType:'danger',
	        //         cancelText:'取消',
	        //         onOk(){
	        //           console.log('rollback')
	        //         },
	        //         onCancel(){
	        //         }
	        //     })
	        // },
	        
		    toquota(e){ //配额
	        e.preventDefault();
	        this.form.validateFields((err,value)=>{
	          if(!err){
							this.spinning = true
							// this.$axios.post(this.allurl+'cephfs/quota',{
							request('post', 'cephfs/operation/setQuotaInDir',{
								// fs_name:this.records.fs_name,
								// path:this.records.path,
								// size:parseInt(value.size),
								// files:parseInt(value.files),
								// unit:value.unit
								dir_name: this.records.name, //目录名称
								max_files: parseInt(value.files), //文件数配额
								max_bytes_number: parseInt(value.size), //容量配额数
								max_bytes_unit: value.unit, //容量配额单位
							}).then(res=>{
								this.model(res.data.id) //返回模板
            	  this.notice(res.data.id, res.data.params, res.data.flag) //通知列表显示
								// this.gettask()  //任务栏信息
								this.spinning = false;
								this.aquota = false;
								this.form.resetFields();
								this.selectedRowKeys = [];
								this.records = '';
								this.getdata()
							}).catch(err => {
								this.spinning = false;
								this.aquota = false;
								this.form.resetFields();
							})
	          }
	        })
				},
			// setmax(rule, value, callback){
			// 	if(value > 18){
			// 		callback('文件数配额不能大于18');
			// 	}else{
			// 		callback();
			// 	}
			// },

			//删除目录结构
			delfile(){
				let _this = this
				this.$confirm({
					title: this.$t('Delete'),
					content:this.$t('Sure-to-del')+": "+_this.records.name+" ？",
					cancelText:this.$t('Cancel'),
					okText:this.$t('Sure'),
					okType:'danger',
					onOk(){
						// _this.$axios({
						// 	method: 'delete',                                 
						// 	// url: _this.allurl+'cephfs/struct',
						// 	url: _this.allurl+'cephfs/operation/',
						// 	data: {
						// 		// fs_name:_this.records.fs_name,
						// 		// path:_this.records.path
						// 		dir_name: _this.records.name,
						// 	}
						// })
						request('DELETE', 'cephfs/operation/', {
							dir_name: _this.records.name,
						})
						.then(res=>{
							// console.log(res)
							_this.model(res.data.id) //返回模板
							_this.notice(res.data.id, res.data.params, res.data.flag) //通知列表显示
							// _this.gettask()  //任务栏信息
							_this.getdata()
							_this.$store.commit('toUpdateSnapPath' ,true);
						})                    
					},
					onCancel(){
					}
				})
			},
	    cancelhandle(){
				this.selectedRowKeys = [];
	    	this.authorize=false
	    	this.form.resetFields();
      	this.spinning=false
	    	this.form2.resetFields();
	    	this.form3.resetFields();
				this.targetPoolName = '';
			},

			//监听配额值发生改变
			quotaSizeChange(e) {
				this.quotaInputValue = Number(e.data);
			},

			//监听配额单位发生改变
			quotaUnitChange(value) {
				this.quotaUnitValue = value;
			},

			//校验选择了单位，是否没有输入配额
			quotaValueValidator(rule, value, callback) {
				if(!value && (this.quotaUnitValue == '' || this.quotaUnitValue== undefined)) {
					this.sizeValidateStatus = 'success';
					this.unitValidateStatus = 'success';
					this.unitValidateHelp = '';
					this.sizeValidateHelp = '';
					callback();
				}else {
					if(!rule.pattern.test(value)) {
						this.sizeValidateStatus = 'error';
						this.sizeValidateHelp = this.$t('Quota_rule_prompt');
						callback(this.$t('Quota_rule_prompt'));
					}else {
						this.sizeValidateStatus = 'success';
						this.sizeValidateHelp = '';
						callback();
					}
				}
			},

			//校验输入了配额，有没有选择单位
			quotaUnitValidator(rule, value, callback) {
				if(!this.quotaInputValue && (value == '' || value==undefined)) {
					this.sizeValidateStatus = 'success';
					this.unitValidateStatus = 'success';
					this.unitValidateHelp = '';
					this.sizeValidateHelp = '';
					callback();
				}else {
					if(this.quotaInputValue && (value==''|| value==undefined)) {
						this.unitValidateStatus = 'error';
						this.unitValidateHelp = this.$t('Choose') + this.$t('Unit');
						callback(this.$t('Choose') + this.$t('Unit'));
					}else {
						this.unitValidateStatus = 'success';
						this.unitValidateHelp = '';
						callback();
					}
				}
			},

			//设置存储池中的改变存储池
			changePool(value) {
				this.poollist.some(item => {
					if(item.poolnum == value) {
						this.targetPoolName = item.poolname;
						return true;
					}
				})
			}
		}
	}
</script>